package yunhe.biz.impl;

import java.util.ArrayList;
import java.util.HashMap;

import org.apache.ibatis.session.SqlSession;

import yunhe.biz.SupplierBiz;
import yunhe.dao.SupplierInte;
import yunhe.entity.Supplier;
import yunhe.util.SqlSessionFactoryUtil;

public class SupBizImpl implements SupplierBiz{
	SqlSession sqlSession=SqlSessionFactoryUtil.getSqlSession();
	SupplierInte supInte=sqlSession.getMapper(SupplierInte.class);
	/**
	 * 添加供应商
	 * @param supplier
	 * @return
	 */
	public boolean addSupplier(Supplier supplier) {
		if (supInte.addSupplier(supplier)) {
			sqlSession.commit();
			return true;
		}else {
			return false;
		}
	}
	/**
	 * 删除供应商
	 * @param supId
	 * @return
	 */
	public boolean delSupplier(String supId) {
		if (supInte.delSupplier(supId)) {
			System.out.println("cg");
			return true;
		}else {
			return false;
		}
	}
	/**
	 * 更改供应商
	 * @param supplier
	 * @return
	 */
	public boolean updateSupplier(Supplier supplier) {
		if (supInte.updateSupplier(supplier)) {
			System.out.println("cg");
			return true;
		}else {
			return false;
		}
	}
	/**
	 * 查询所有供应商
	 * @return
	 */
	public ArrayList<Supplier> getAllSupplier(HashMap<String,String> searchMap) {
		ArrayList<Supplier> supList=supInte.getAllSupplier(searchMap);
		return supList;
	}
	/**
	 * 分页查询供应商
	 * @param curPage
	 * @param pageSize
	 * @return
	 */
	public ArrayList<Supplier> getSupByPage(int curPage, int pageSize){
		ArrayList<Supplier> supList=supInte.getSupByPage(curPage, pageSize);
		return supList;
	}
	/**
	 * 查询供应商总条数
	 * @return
	 */
	public int getSupCount(){
		return supInte.getSupCount();
	}
}
